package com.qf.boot2202day02.config;

import com.qf.boot2202day02.dao.UserDao;
import com.qf.boot2202day02.servlet.HelloServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
public class ServletConfig {

    @Autowired
    UserDao userDao;


    @Bean
    public ServletRegistrationBean<HelloServlet> servletServletRegistrationBean(){

        final ServletRegistrationBean<HelloServlet> registrationBean = new ServletRegistrationBean<>();

        // serlet的配置信息通过方法调用实现

        registrationBean.addUrlMappings("/hello");

        final HelloServlet helloServlet = new HelloServlet();

        helloServlet.setUserDao(userDao);

        registrationBean.setServlet(helloServlet);

        return registrationBean;

    }


}
